const path: string = "/environment_sla/_doc";

// 基础信息
const getBasics = (nodePath: string) => {
  const data = fetch(`${path}/${nodePath}?_source=basic`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  }).then((response) => response.json());

  return data;
};

// 初始化检查
const getGeneralCheck = (nodePath: string) => {
  const data = fetch(`${path}/${nodePath}?_source=generalcheck`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  }).then((response) => response.json());

  return data;
};

// 个性化检查
const getPersonalCheck = (nodePath: string) => {
  const data = fetch(`${path}/${nodePath}?_source=personalcheck`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  }).then((response) => response.json());

  return data;
};

// 应用信息
const getServiceInfo = (nodePath: string) => {
  const data = fetch(`${path}/${nodePath}?_source=service`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  }).then((response) => response.json());

  return data;
};

// 定时任务
const getTimedTask = (nodePath: string) => {
  const data = fetch(`${path}/${nodePath}?_source=cronnum,cron`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  }).then((response) => response.json());

  return data;
};

export {
  getBasics,
  getGeneralCheck,
  getPersonalCheck,
  getServiceInfo,
  getTimedTask,
};
